// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 * TEMPLATE:    SpringServiceImpl.vsl in andromda-spring cartridge
 * MODEL CLASS: AndroMDAModel::JR Appointment Service::com.systemsjr.jrappointment::setting::service::SystemSettingService
 * STEREOTYPE:  Service
 */
package com.systemsjr.jrappointment.setting.service;

import com.systemsjr.jrappointment.setting.SystemSetting;
import com.systemsjr.jrappointment.setting.SystemSettingDao;
import com.systemsjr.jrappointment.setting.vo.SystemSettingSearchCriteria;
import com.systemsjr.jrappointment.setting.vo.SystemSettingVO;

import java.util.Collection;
import java.util.List;

/**
 * @see com.systemsjr.jrappointment.setting.service.SystemSettingService
 */
public class SystemSettingServiceImpl
    extends SystemSettingServiceBase
{

    /**
     * @see com.systemsjr.jrappointment.setting.service.SystemSettingService#delete(SystemSettingVO)
     */
    protected  void handleDelete(SystemSettingVO settingVO)
        throws Exception
    {
    	if(settingVO.getId() != null){
    		getSystemSettingDao().remove(settingVO.getId());
    	}
    }

    /**
     * @see com.systemsjr.jrappointment.setting.service.SystemSettingService#save(SystemSettingVO)
     */
    protected  SystemSettingVO handleSave(SystemSettingVO settingVO)
        throws Exception
    {
    	SystemSetting setting = getSystemSettingDao().systemSettingVOToEntity(settingVO);
    	
    	if(settingVO.getId() == null){
    		setting = getSystemSettingDao().create(setting);
    	} else{
    		getSystemSettingDao().update(setting);
    	}
    	
    	return getSystemSettingDao().toSystemSettingVO(setting);
    }

    /**
     * @see com.systemsjr.jrappointment.setting.service.SystemSettingService#loadAll()
     */
    protected  Collection<SystemSettingVO> handleLoadAll()
        throws Exception
    {
    	
    	return (Collection<SystemSettingVO>) getSystemSettingDao().loadAll(SystemSettingDao.TRANSFORM_SYSTEMSETTINGVO);
    }

    /**
     * @see com.systemsjr.jrappointment.setting.service.SystemSettingService#search(SystemSettingSearchCriteria)
     */
    protected  Collection<SystemSettingVO> handleSearch(SystemSettingSearchCriteria searchCriteria)
        throws Exception
    {
    	return getSystemSettingDao().toSystemSettingVOCollection(getSystemSettingDao().findByCriteria(searchCriteria));
    }

}